package com.first.teacher.controller;

import com.first.common.pojo.EduTeacher;
import com.first.common.vo.Result;
import com.first.teacher.service.ShouCangService;
import com.first.teacher.vo.GuanZhuVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: finrsteducation-parent
 * @description:
 * @author: 张玉森
 * @create: 2023-06-06 14:39
 **/
@RestController
@RequestMapping("/core/shoucangTeacher")
@Api(tags = "教师关注类接口")
public class ShouCangTeacherController {
    @Autowired
    private ShouCangService shouCangService;


    @PostMapping("findAttentionTeacher")
    @ApiOperation("进入页面渲染是否已经关注")
    private Result findAttentionTeacher(@RequestBody GuanZhuVo guanZhuVo){
        Long number= shouCangService.findAttentionTeacher(guanZhuVo);
        Map<String,Integer> map=new HashMap<>();
        if (number==0){
            map.put("status",0);
        }else {
            map.put("status",1);
        }
        return Result.success(map);
    }
    @PostMapping("deleteAttentionTeacher")
    @ApiOperation("取消关注老师")
    public Result deleteAttentionTeacher(@RequestBody GuanZhuVo guanZhuVo){
        Integer delete= shouCangService.deleteAttentionTeacher(guanZhuVo);
        if (delete>0){
            return Result.success();
        }else {
            return Result.fail("取消关注失败");
        }
    }
    @PostMapping("addAttentionTeacher")
    @ApiOperation("关注讲师")
    public Result addAttentionTeacher(@RequestBody GuanZhuVo guanZhuVo) {
        Integer add = shouCangService.addAttentionTeacher(guanZhuVo);
        if (add > 0) {
            return Result.success();
        } else {
            return Result.fail("关注失败");
        }
    }

    @ApiOperation("导师信息查询")
    @PostMapping("findTeacherBYMobile/{teacherMobile}")
    public EduTeacher findone(@PathVariable String teacherMobile){
        return shouCangService.findTeacherBYMobile(teacherMobile);
    }

    @PostMapping("findAttentionTeacher2/{HuiYuanId}")
    @ApiOperation("进入页面渲染是否已经关注")
    private Result findAttentionTeacher2(@PathVariable String HuiYuanId){
        List<EduTeacher> attentionTeacher2 = shouCangService.findAttentionTeacher2(HuiYuanId);
        return Result.success(attentionTeacher2);
    }

}
